package dataexchange.communication.http;


import dataexchange.communication.ICommunication;
import dataexchange.exception.CommunicationException;
import sun.net.www.http.HttpClient;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by cwtao on 2017-05-10.
 */
public class HttpCommunication implements ICommunication {
    @Override
    public String swapData(String sendString) throws CommunicationException {
        String urlPath = null;
        URL url = null;
        try {
            url = new URL(urlPath);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

        HttpClient httpClient = null;
        try {
            httpClient = HttpClient.New(url);
        } catch (IOException e) {

        }
        
        return null;
    }

    public String[][] toKeyValue(String sendString) {
        String[] allParam = sendString.split("&");
        String[][] keyvalues = new String[allParam.length][2];
        for (int i = 0; i < allParam.length; i++) {
            keyvalues[i] = allParam[i].split("=");
        }
        return keyvalues;
    }
}
